﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; 
using System.Linq;
using System.Web;

namespace Keepo.Models.Services
{
    public class TemplatePageExport
    {
        public TemplatePageExport() { }

        public int TemplatePageId { get; set; }
        
        public string Title { get; set; }
        public int PageIdx { get; set; }

        // The Width of XML Project in Pixels 
        public float XmlWidthPix { get; set; }
        public float XmlHeightPix { get; set; }

        // Height and Width Of Template
        public float TemplateWidthPix { get; set; }
        public float TemplateHeightPix { get; set; }

        // Thumbnail 
        public String ThumbnailURL { get; set; }
        public int ThumbnailWidthPix { get; set; }
        public int ThumbnailHeightPix { get; set; }

        // Image and ROI [ non transparent region ]
        public string ImageURL { get; set; }
        public int ImageRoiWidthPix { get; set; }
        public int ImageRoiHeightPix { get; set; }
        public int ImageRoiOffsetXPix { get; set; }
        public int ImageRoiOffsetYPix { get; set; }

        public int DesignTemplateId { get; set; }


        public TemplatePageExport(TemplatePage page) 
        {
            this.Title = page.Title;
            this.PageIdx = page.PageIdx;

            this.XmlWidthPix = page.XmlWidthPix;
            this.XmlHeightPix = page.XmlHeightPix;

            this.TemplateWidthPix = page.TemplateWidthPix;
            this.TemplateHeightPix = page.TemplateHeightPix;

            this.ThumbnailURL = page.ThumbnailURL;
            this.ThumbnailWidthPix = page.ThumbnailWidthPix;
            this.ThumbnailHeightPix = page.ThumbnailHeightPix;

            this.ImageURL = page.ImageURL;
            this.ImageRoiWidthPix = page.ImageRoiWidthPix;
            this.ImageRoiHeightPix = page.ImageRoiHeightPix;
            this.ImageRoiOffsetXPix = page.ImageRoiOffsetXPix;
            this.ImageRoiOffsetYPix = page.ImageRoiOffsetYPix;

            this.DesignTemplateId = page.DesignTemplateId;
        }

        public TemplatePage toEntity()
        {
            TemplatePage page = new TemplatePage();

            page.Title = this.Title;
            page.PageIdx = this.PageIdx;

            page.XmlWidthPix = this.XmlWidthPix;
            page.XmlHeightPix = this.XmlHeightPix;

            page.TemplateWidthPix = this.TemplateWidthPix;
            page.TemplateHeightPix = this.TemplateHeightPix;

            page.ThumbnailURL = this.ThumbnailURL;
            page.ThumbnailWidthPix = this.ThumbnailWidthPix;
            page.ThumbnailHeightPix = this.ThumbnailHeightPix;

            page.ImageURL = this.ImageURL;
            page.ImageRoiWidthPix = this.ImageRoiWidthPix;
            page.ImageRoiHeightPix = this.ImageRoiHeightPix;
            page.ImageRoiOffsetXPix = this.ImageRoiOffsetXPix;
            page.ImageRoiOffsetYPix = this.ImageRoiOffsetYPix;

            page.DesignTemplateId = this.DesignTemplateId;

            return page;
        }

    }
}